package org.example.bean.entity.product;

import com.bianmaba.spring.data.jpa.domain.annotations.QueryCacheable;
import com.bianmaba.spring.data.jpa.domain.entity.BaseEntity;
import lombok.Data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * @program: example-web-framework-extends-2x
 * @description:
 * @author: Chenjiabin
 * @create: 2018-04-22 20:29
 **/
@DynamicUpdate(true)
@DynamicInsert(true)
@Entity
//此注解重新定义为是否开启查询缓存
@QueryCacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "Product")
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"name"})})
@Data
public class Product extends BaseEntity {
    @Column(nullable = false, length = 255)
    private String name;

    @Column(nullable = false, length = 32)
    private String no;

    @Column(nullable = false)
    private String smallImage;

    @Column()
    private Double marketPrice;

    @Column()
    private Double price;

    @Column(columnDefinition = "TEXT")
    private String description;

    @Column(nullable = false)
    private Boolean enabled = true;

    @Column()
    private Integer hits;

    @Column()
    private Integer idx = 0;

    private String test[];
}
